using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace MCGameEngine
{
    public class Repository<T>
    {
        private Dictionary<string, T> elements;
        private ContentManager content;

        public Repository(ContentManager content)
        {
            elements = new Dictionary<string, T>();
            this.content = content;
        }

        public T Element(string name)
        {
            try
            {
                return elements[name];
            }
            catch
            {
                T m = content.Load<T>(name);
                elements.Add(name, m);
                return m;
            }
        }

        public T this[string key]
        {
            get
            {
                return Element(key);
            }
            set
            {
                elements[key] = value;
            }
        }

    }
}
